package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.Blog;
import com.example.demo.entity.User;
import com.example.demo.mapper.Blogmapper;
import com.example.demo.service.Blogservice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Service
public class Blogserviceimpl implements Blogservice {
    @Resource
    Blogmapper blogmapper;
/*    @Override
    public List<Blog> selectAll(Integer PageIndex, Integer PageSize) {
        return blogmapper.selectAll(PageIndex,(PageIndex-1)*PageSize);
    }*/

    @Override
    public Page<Blog> selectAll(Page<Blog> page, Wrapper<Blog> queryWrapper) {
        return blogmapper.selectPage(page, queryWrapper);
    }

    @Override
    public Page<Blog> selectAka(Page<Blog> page, String title, Integer type_id) {
        return blogmapper.selectAka(page,title,type_id);
    }

    @Override
    public int dele(int id) {
        return blogmapper.deleteById(id);
    }

    @Override
    public int inse(Blog blog) {
        return blogmapper.insert(blog);
    }



    @Override
    public Page<Blog> selectA(Page<Blog> page, int typeId, int tagIds) {
        return blogmapper.selectA(page,typeId,tagIds);
    }

    @Override
    public Blog selectToid(int id) {
        return blogmapper.selectToid(id);
    }

    @Override
    public int sel(int id) {
        return blogmapper.sel(id);
    }
    @Override
    public int update(Blog blog) {
        return blogmapper.updateById(blog);
    }

    @Override
    public int TagselectByia(int id) {
        return blogmapper.TagselectByia(id);
    }

    @Override
    public List<Blog> recommend() {
        return blogmapper.recommend();
    }

    @Override
    public List<Blog> selectByU() {
        return blogmapper.selectByU();
    }

    @Override
    public int countasa() {
        return blogmapper.countasa();
    }

    @Override
    public Map<Integer, List<Blog>> selectma() {
        List<Integer> selectpp = blogmapper.selectpp();
        Map<Integer,List<Blog>> map = new LinkedHashMap<>();
        for (Integer integer : selectpp) {
            List<Blog> blogs = blogmapper.selectNf(integer);
            map.put(integer,blogs);
        }
        return map;
    }
    @Override
    public Blog slsct(Long id) {
        return blogmapper.slsct(id);
    }

    @Override
    public Page<Blog> selectAkaa(Page<Blog> page, String title) {
        return blogmapper.selectAkaa(page,title);
    }
}
